<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>

<script>
description("Tests the digest() method using ArrayBuffer");

jsTestIsAsync = true;

var algorithmName = "sha-256";
var inputHex = "00";
var expectedOutputHex = "6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d";

// Most of the crypto LayouTests use ArrayBufferView for data input. This one
// passes an ArrayBuffer instead.
var input = hexStringToUint8Array(inputHex).buffer;

crypto.subtle.digest({name : algorithmName}, input).then(function(result) {
    bytesShouldMatchHexString("sha-256 of [0]", expectedOutputHex, result);
}).then(finishJSTest, failAndFinishJSTest);

</script>

</body>
</html>
